/**************************************************************/
/*  This file is licensed from, and is a trade secret of:     */
/*                                                            */
/*    Mercury Computer Systems, Incorporated                  */
/*    199 Riverneck Road                                      */
/*    Chelmsford, Massachusetts 01824-2820                    */
/*    United States of America                                */
/*    Telephone + 1 978 256-1300                              */
/*                                                            */
/*  Refer to your Software License Agreement for provisions   */
/*  on use, duplication, or disclosure.                       */
/*  US. Government users and prime contractors are also       */
/*  governed by the following Data Rights Notice:             */
/*  Use, duplication or disclosure by the US. Government is   */
/*  subject to the provisions set forth in FAR 52.227-14 for  */
/*  restricted rights or other agency data rights provisions  */
/*  on commercial software and documentation, as applicable.  */
/*                                                            */
/*  This file: (a) was developed at private expense, and no   */
/*  part was developed with government funds, (b) is a        */
/*  trade secret of Mercury Computer Systems, Inc. for the    */
/*  purposes of the Freedom of Information Act, (c) is        */
/*  "commercial computer software" subject to limited         */
/*  utilization as provided in the above noted Software       */
/*  License Agreement and (d) is in all respects data         */
/*  belonging exclusively to Mercury Computer Systems, Inc..  */
/*                                                            */
/**************************************************************/

/******************************************************************/
/* Copyright ¨ 1999-2003, Mercury Computer Systems, Inc.,         */
/* Chelmsford MA.,and all third party embedded software sources.  */
/* All rights reserved under the Copyright laws of US. and        */
/* international treaties.                                        */
/*                                                                */
/* Patent Pending                                                 */
/******************************************************************/


//$COPYRIGHT_END


/*
 * Abstact:
 *   Base class for SCA parser exceptions
 *
 *
 */

#ifndef SCA_EXCEPTION_H
#define SCA_EXCEPTION_H

//#include "SceUtils.h"
#include <ostream>
#include <cstring>

using namespace std;

#if 1 // 1 for static library
#define SCA_XML_PARSE_API
#else
#ifdef SCA_XML_PARSE_EXPORTS
#define SCA_XML_PARSE_API __declspec(dllexport)
#else
#define SCA_XML_PARSE_API __declspec(dllimport)
#endif
#endif


class SCA_XML_PARSE_API SCA_Exception
{


  // friends
 // friend ostream& operator<<( ostream& os, SCA_Exception& me );

  // Exception name
 public:
  const char* name_;
    
  // Exception message
  const char* msg_;

  // Exception message
  const char* aux_msg_;

 public:

  // Constructor
  SCA_Exception(){init(NULL,NULL,NULL);}
  SCA_Exception( const char* name, const char* msg ){init(name,msg,NULL);}
  SCA_Exception( const char* name, const char* msg, const char* aux_msg )
  {init(name,msg,aux_msg);}
  SCA_Exception( const char* name, const char* msg, char* aux_msg )
  {init(name,msg,(const char*)aux_msg);}
  SCA_Exception(const SCA_Exception &ex)
  {init(ex.GetName(),ex.GetErrorMessage(),ex.GetAuxMessage());}


  // Destructor
  virtual ~SCA_Exception()
  {
	  if(name_)free((void*)name_);
	  if(msg_)free((void*)msg_);
	  if(aux_msg_)free((void*)aux_msg_);
  }

  // Get exception name
  virtual const char* GetName() const {return name_;}
  
  // Get exception message
  virtual const char* GetErrorMessage() const {return msg_;}

  // Get aux msg
  virtual const char* GetAuxMessage() const {return aux_msg_;}

 private:

	 void init( const char* name, const char* msg, const char* aux )
	 {
		 if ( name ) {
			name_ = strdup(name);
		 }
		 else {
			name_ = NULL;
		 }
		 if ( msg ) {
			msg_ = strdup(msg);
		 }
		 else {
			msg_ = NULL;
		 }
		 if ( aux ) {
			aux_msg_ = strdup(aux);
		 }
		 else {
			aux_msg_ = NULL;
		 }	
	 }
};


#ifdef NEED_OS_OPERATOR
inline ostream& operator<<( ostream& os, SCA_Exception& ex )
{
	
	os << ex.name_ << " : " << ex.msg_ << " : " << ex.aux_msg_.data() << endl;
	return os;
}
#endif



#endif




